package com.ruoyi.system.mapper;

import java.util.List;

import com.ruoyi.system.domain.ProjectUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 项目人员Mapper接口
 *
 * @author ruoyi
 * @date 2025-03-11
 */
public interface ProjectUserMapper extends BaseMapper<ProjectUser> {


    @Select("SELECT " +
            " a.*, " +
            " b.`name` AS projectName, " +
            " c.nick_name AS userName,  " +
            " ( select GROUP_CONCAT(r.role_name) from sys_user_role as  ur left join sys_role r on r.role_id = ur.role_id where ur.user_id = c.user_id) as roleNames " +
            "FROM " +
            " project_user AS a " +
            " LEFT JOIN project AS b ON ( a.project_id = b.id ) " +
            " LEFT JOIN sys_user AS c ON ( a.user_id = c.user_id )  " +
            "WHERE " +
            " a.project_id = #{projectId} and c.del_flag = '0'")
    List<ProjectUser> getList(@Param("projectId") Integer projectId);
}
